﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

namespace ApiCoreProject.Bll
{
    public interface IBaseBll<T> where T : class, new()
    {
        /// <summary>
        /// 增加
        /// </summary>
        /// <param name="t"></param>
        T Add(T t, bool isSave);
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="t"></param>
        void Delete(T t, bool isSave);
        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="t"></param>
        void DeleteBatch(List<T> list, bool isSave);
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="t"></param>
        void Update(T t, bool isSave);
        /// <summary>
        /// 搜索
        /// </summary>
        /// <param name="whereLambda">Lambda表达式</param>
        /// <returns></returns>
        IQueryable<T> GetModels(Expression<Func<T, bool>> whereLambda);

        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="pageSize">每页显示多少</param>
        /// <param name="pageIndex">当前页码</param>
        /// <param name="isAsc">是否升序</param>
        /// <param name="whereLambda">Lambda</param>
        /// <returns></returns>
        IQueryable<T> GetModelsByPage<type>(int pageSize, int pageIndex, bool isAsc, Expression<Func<T, type>> orderByLambda, Expression<Func<T, bool>> whereLambda);
        /// <summary>
        /// 保存
        /// </summary>
        /// <returns></returns>
        int SaveChanges();
    }
}
